Skip to content

Conversation

maurycy
Copy link
Contributor

@maurycy maurycy commented Aug 20, 2025

Please see for the code:

  • cpython/Modules/_csv.c

    Lines 1253 to 1267 in 7dc42b6

    if (!field_len && dialect->delimiter == ' ' && dialect->skipinitialspace) {
    if (dialect->quoting == QUOTE_NONE ||
    (field == NULL &&
    (dialect->quoting == QUOTE_STRINGS ||
    dialect->quoting == QUOTE_NOTNULL)))
    {
    PyErr_Format(self->error_obj,
    "empty field must be quoted if delimiter is a space "
    "and skipinitialspace is true");
    return 0;
    }
    quoted = 1;
    }
    rec_len = join_append_data(self, field_kind, field_data, field_len,
    &quoted, 0);

Please see the test:

The behavior is intentional since gh-115721, so the only sensible route is to update the docs.


📚 Documentation preview 📚: https://cpython-previews--138006.org.readthedocs.build/

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is too verbose. The note takes up a lot of space and attracts a disproportionate amount of attention. Most users will never encounter this, and if they do, this behavior is expected and therefore does not require any special explanation.

Could you please limit yourself to one short sentence? That such CSV files cannot contain empty fields.

@maurycy
Copy link
Contributor Author

maurycy commented Aug 21, 2025

I think this is too verbose. The note takes up a lot of space and attracts a disproportionate amount of attention. Most users will never encounter this, and if they do, this behavior is expected and therefore does not require any special explanation.

Could you please limit yourself to one short sentence? That such CSV files cannot contain empty fields.

Thank you for taking a look. Made it much shorter:

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 22, 2025
Copy link
Contributor

@sharktide sharktide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
And thanks for fixing the typo :)

@hugovk hugovk merged commit e0f54a6 into python:main Sep 11, 2025
35 checks passed
@miss-islington-app
Copy link

Thanks @maurycy for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Sep 11, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 11, 2025
…iter=' '` require quotation for empty fields (pythonGH-138006)

(cherry picked from commit e0f54a6)

Co-authored-by: Maurycy Pawłowski-Wieroński <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 11, 2025
…iter=' '` require quotation for empty fields (pythonGH-138006)

(cherry picked from commit e0f54a6)

Co-authored-by: Maurycy Pawłowski-Wieroński <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Sep 11, 2025

GH-138798 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Sep 11, 2025
@bedevere-app
Copy link

bedevere-app bot commented Sep 11, 2025

GH-138799 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 11, 2025
hugovk pushed a commit that referenced this pull request Sep 11, 2025
…miter=' '` require quotation for empty fields (GH-138006) (#138798)

Co-authored-by: Maurycy Pawłowski-Wieroński <[email protected]>
hugovk pushed a commit that referenced this pull request Sep 11, 2025
…miter=' '` require quotation for empty fields (GH-138006) (#138799)

Co-authored-by: Maurycy Pawłowski-Wieroński <[email protected]>
@maurycy maurycy deleted the csv-rst-typo branch September 13, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants